package com.wyy.service.impl;

import com.wyy.bean.Student;
import com.wyy.dao.StudentDao;
import com.wyy.dao.impl.StudentDaoImpl;
import com.wyy.service.StudentService;

import java.util.List;

/**
 * @ClassName UsersServiceImpl
 * @Description //TODO
 * @Author wky
 * @Date 2021/9/12 14:55
 * @Version 1.0
 **/
public class StudentServiceImpl implements StudentService {
    
    private StudentDao studentDao = new StudentDaoImpl();
    
    @Override
    public List<Student> getStudents(String name,String stuno,int sex,int pageIndex,int pageSize) {
        return studentDao.getStudents(name,stuno,sex,pageIndex,pageSize);
    }
    
    @Override
    public int total(String name, String stuno, int sex) {
        return studentDao.total(name,stuno,sex);
    }
    
    @Override
    public int insertStu(Student student) {
        Student stu = studentDao.findByStuNo(student.getStuNo());
        if (stu==null)//如果该学号不存在，则插入该学生信息
            return studentDao.insertStu(student);
        else //如果该学号存在 则提示重新输入
            return -1;
    }
    
    @Override
    public Student findById(int sid) {
        return studentDao.findById(sid);
    }
    
    @Override
    public int updateStu(Student student) {
        return studentDao.updateStu(student);
    }
    
    @Override
    public int delStu(String sid) {
        return studentDao.delStu(sid);
    }
}
